﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utilities.Expand
{
    public static class Expands
    {
        public static byte[] GetBytes(this string param, string encodingtype = "utf-8")
        {
            switch (encodingtype.ToString().ToLower())
            {
                case "utf-8":
                    {
                        return Encoding.UTF8.GetBytes(param);
                    }
                case "gbk":
                    {
                        return Encoding.Default.GetBytes(param);
                    }
                default:
                    {
                        return Encoding.UTF8.GetBytes(param);
                    }
            }
        }


        public static string ToMD5(this string param)
        {

            return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(param, "MD5");
        }

        public static string GetString(this byte[] param)
        {
            return Encoding.UTF8.GetString(param);
        }
    }
}
